package officeserver.main;

import java.io.Serializable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;

import officeserver.log_error.Log;
import officeserver.log_error.OfficeException;
import officeserver.log_error.UserException;
import officeserver.office.Office;
import officeserver.office.network.NetworkConnectionManager;
import officeserver.office.network.RequestQueueManager;
import officeserver.users.AccessLevel;
import officeserver.users.UserList;

/**
 * @author Chris Bayruns The entry point to the application. And for testing.
 * @version $Revision: 1.0 $
 */
public class Main implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
     * @param args
     */

    public static final String FILE_OUT_NAME = new String("userList.list");

    public static final int MAXLOGINS = 3;

    public static void main(String[] args) {// The logging server was moved to
	// Log.java
	Log.initLogger();

	Office temp = new Office();
	try
	{
		temp.load();
	}
	catch (OfficeException e)
	{
	    UserList.clear();
	    try
		{
			UserList.addUser("admin", "admin", "admin", "admin1",
			    AccessLevel.ADMIN);
			UserList.addUser("nurse","nurse","nurse","nurse1",AccessLevel.NURSE);
		}
		catch (UserException e1)
		{
			// TODO Auto-generated catch block
			//e1.printStackTrace();
		}
	}
	System.out.println("Starting up the server.");
    NetworkConnectionManager serverNet = new NetworkConnectionManager(12345);
    RequestQueueManager queueNet = new RequestQueueManager();

    ExecutorService pool = Executors.newFixedThreadPool(2);
    pool.execute(serverNet);
    pool.execute(queueNet);
    

    }


    /**
     * Method toString.
     * 
     * @return String
     */
    public String toString() {
	return null;
    }
}
